/**
 * 
 */
package example;

import weibo4j.User;
import weibo4j.Weibo;
import weibo4j.WeiboException;


public class CreateFriendship {

	/**
	 * 关注某用户 
	 * @param args
	 */
	public static void main(String[] args) {
		System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
    	System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
		try {
			
			//关注人的id
			String id = "joechen";
			
			User user = getWeibo(false,args).createFriendship(id);//args[2]:关注用户的id
			System.out.println(user.toString());
		} catch (WeiboException e) {
			e.printStackTrace();
		}
	}
	
	private static Weibo getWeibo(boolean isOauth,String ... args) {
		Weibo weibo = new Weibo();
		if(isOauth) {//oauth验证方式 args[0]:访问的token；args[1]:访问的密匙
			weibo.setToken("995460685f6ea3265d550232eca1ef26","8a39d3ccca3739f773a9b9e2a2150097");
		}else {//用户登录方式
    		weibo.setUserId("371475640@qq.com");//用户名/ID
    		weibo.setPassword("twigetor");//密码
		}
		return weibo;
	}

}